/**
* \file DGVDiophantineVTK.h
*
* \brief This file defines a class for drawing lines on lattices.
* \author Shekhar S. Chandra, 2008
*
* This file is part of DGV Library.
*
* DGV is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DGV is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DGV.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DGVDIOPHANTINEVTK_H
#define DGVDIOPHANTINEVTK_H

#include "QVTKWidget.h"

#include "DGVLatticeVTK.h"

#include "vtkLineSource.h"
#include "vtkProperty.h"

typedef long DiophantineType;

/*!
    \class DGVDiophantineVTK
    \brief This class represents the Diophantine functions drawn on DGVLatticeVTK classes using VTK for display. EXPERIMENTAL
    \author Shekhar S. Chandra, 2008

    Diophantine File Format:
    \code
	#Primary Lattice Size and then colour (rgb)
    #"xSize ySize r g b"
    13 13 0 0 0
    #Secondary Lattice Size and then colour (rgb)
    #"xSize ySize r g b"
    13 13 0 0 0
    #Background colour (rgb). Negative colours will use default
    #"r g b"
    255 255 255
    #Parameters for lines or points
    #Define lines as point on line (x,y) and then colour (rgb)
    #and then gradient (p,q).
    #If no gradient is provided then the
    #parameters are taken to be defining a point and its colour
    #Define a vector by points (x,y) and (u,v)
    #Redefine colour for vectors with a triple (r,g,b)
    #All Points are taken with respect to the secondary lattice
    #"x y r g b p q"
    #or "x y r g b"
    #or "x y u v"
    #or "r g b"
    4 4 256 0 0 1 1
    \endcode
*/
class DGV_VTK_EXPORT DGVDiophantineVTK : public QVTKWidget
{
public:
    DGVDiophantineVTK(QWidget *parent = 0);
    virtual ~DGVDiophantineVTK();

    void setLattice(DGVLatticeVTK *lattice);
    void setCoefficients(DiophantineType x, DiophantineType y, DiophantineType z);
    void setPointOnLine(DiophantineType x, DiophantineType y, DiophantineType z);
    void setStartPoint(Array<DiophantineType,1> &point);
    void setStartPoint(DiophantineType x, DiophantineType y);
    void setEndPoint(Array<DiophantineType,1> &point);
    void setEndPoint(DiophantineType u, DiophantineType v);
    void setColour(double red, double green, double blue);

    vtkActor* getLineActor()
    {   return actor;   }

    DGVLatticeVTK* loadFile(QString filename);
    void generateLine();

protected:
    DGVLatticeVTK *gamma; //!< Fundamental Lattice Gamma
    DiophantineType xCoefficient;
    DiophantineType yCoefficient;
    DiophantineType zCoefficient;
    Array<DiophantineType,1> pointOnLine; //!< Point on the line (coordinate)
    Array<double,1> start;
    Array<double,1> end;
    DiophantineType intercept;
    bool latticeSet;
    bool generatedBefore;
    bool manual; //!< Has the end points been set manually?

    vtkLineSource *line; //!< Line form
    vtkPolyDataMapper *mapper; //!< Map of the line
    vtkActor *actor; //!< Actor for the line
    vtkProperty *displayProperties; //!< Display properties of the line
};

#endif // DGVDIOPHANTINEVTK_H
